package sh.action;

import com.opensymphony.xwork2.ActionSupport;
import lombok.Data;
import sh.model.Message;
import sh.model.User;
import sh.service.MessageService;
import sh.service.UserService;
import sh.service.impl.MessageServiceImpl;
import sh.service.impl.UserServiceImpl;

import java.util.List;

@Data
public class UserAction extends ActionSupport{
	private List<User> users;
	private List<Message> messages;
	private String userName;
	private Long userId;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	//查看所有用户
	@Override
	public String execute() throws Exception {
		UserService userService = new UserServiceImpl();
		users = userService.getAllUsers();
		return super.execute();
	}
	//查看留言
	public String getMessage(){
		MessageService ms = new MessageServiceImpl();
		this.setMessages(ms.getByUserId(userId));
		return "success";
	}
	

}
